﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Web.DynamicData;
using System.Data;

namespace badminton
{
    public partial class _Admin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables;
            if (visibleTables.Count == 0)
            {
                throw new InvalidOperationException("没有可访问的表。请确保在 Global.asax 中注册了至少一个数据模型并启用了基架，或者实现自定义页面。");
            }
            DataTable tbl = new DataTable();
            tbl.Columns.Add("name");
            tbl.Columns.Add("url");
            DataRow drow;
            foreach (Object obj in visibleTables)
            {
                MetaTable mt = obj as MetaTable;
                drow = tbl.NewRow();
                drow["url"] = mt.ListActionPath;
                drow["name"] = mt.DisplayName;
                //if (mt.Name=="CourtSchedule")
                //{
                //    drow["url"] = "./AdminPages/CourtSchedule.aspx";
                //}

                tbl.Rows.Add(drow);
            }

            Menu1.DataSource = tbl;
            Menu1.DataBind();
        }

    }
}
